﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void YGRQCXS(DataSet db)
        {
            try
            {
                exAgent.SetCurrentSheet("YGRQCXS");
                DataTable dtSoruce = db.Tables["ABFOLGE"];
                DataTable dtOutput = new DataTable();
                int idx = 1;
                exAgent.SetCellValue(3, idx++, "批号"); dtOutput.Columns.Add("GPPARTIE", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "质检单号"); dtOutput.Columns.Add("QOKORDER", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "品种"); dtOutput.Columns.Add("ABPART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "色号"); dtOutput.Columns.Add("ABPFARBE", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "日期"); dtOutput.Columns.Add("QOKNEUD", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "纱型"); dtOutput.Columns.Add("TYP", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "支数值"); dtOutput.Columns.Add("X001", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "纱支折算系数"); dtOutput.Columns.Add("X002", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "实际号数"); dtOutput.Columns.Add("X003", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "回潮率%"); dtOutput.Columns.Add("X004", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "重量偏差"); dtOutput.Columns.Add("X005", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "实际支数"); dtOutput.Columns.Add("X006", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "重量CV%"); dtOutput.Columns.Add("X007", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "条干CV%"); dtOutput.Columns.Add("X008", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "细节-50%"); dtOutput.Columns.Add("X009", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "粗节+50%	"); dtOutput.Columns.Add("X010", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "棉结+140%"); dtOutput.Columns.Add("X011", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "棉结+200%"); dtOutput.Columns.Add("X012", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "棉结+280%"); dtOutput.Columns.Add("X013", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "毛羽H"); dtOutput.Columns.Add("X014", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "单强CN"); dtOutput.Columns.Add("X015", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "最小强力CN"); dtOutput.Columns.Add("X016", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "单强CV%"); dtOutput.Columns.Add("X017", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "强度CN/TEX"); dtOutput.Columns.Add("X018", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "断裂伸长E"); dtOutput.Columns.Add("X019", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "捻度T/10CM"); dtOutput.Columns.Add("X020", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "捻度CV%"); dtOutput.Columns.Add("X021", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "备注"); dtOutput.Columns.Add("X050", typeof(System.String));  
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["GPPARTIE"] = GetGB2312Value(row["GPPARTIE"].ToString());
                    row["ABPFARBE"] = GetGB2312Value(row["ABPFARBE"].ToString());
                    row["X050"] = GetGB2312Value(row["X050"].ToString());
                }
                exAgent.DataTableToExcel(dtOutput, 4, 1);

                int count = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1);
                exAgent.BatchConvert2Number(4, 2, count + 3, 2);
                exAgent.BatchConvert2Number(4, 7, count + 3, 27);
                exAgent.SetCellValue(1, 1, "细纱质量");

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
    }
}